package
{
	import Olivia.olivia3d.Olivia3D;
	import Olivia.olivia3d.vo.Ms3dVo;
	
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	import flash.geom.Vector3D;
	import flash.ui.Keyboard;
	
	[SWF(width="800", height="600", backgroundColor="#ffffff", frameRate="31")]
	public class GLD extends Sprite
	{
		private var kms3d:Ms3dVo = new Ms3dVo();
		public function GLD()
		{
			Olivia3D.ins.init(this);
//			kms3d.position.w = 45;
			kms3d.position.x = 40;
			Olivia3D.ins.addModel("panel.ms3d",new Ms3dVo());
			Olivia3D.ins.addModel("kiko.ms3d",kms3d,1);
			Olivia3D.ins.addModel("hui.ms3d",new Ms3dVo());
			addKeyboard();
//			stage.addEventListener(MouseEvent.MOUSE_MOVE,addMouseMove);
		}
		
		private function addMouseMove(e:MouseEvent):void
		{
			// TODO Auto Generated method stub			
			var rawdata:Vector.<Number> = new Vector.<Number>(16);
			Olivia3D.ins.mainCamera.projection.copyRawDataTo(rawdata);
			rawdata[8] = stage.mouseX/800*2;
			rawdata[9] = -stage.mouseY/600*2;
			Olivia3D.ins.mainCamera.projection.copyRawDataFrom(rawdata);
		}
		
		private function addKeyboard():void
		{
			// TODO Auto Generated method stub
			stage.addEventListener(KeyboardEvent.KEY_DOWN, 
				function(e:KeyboardEvent):void{
					if(e.keyCode == Keyboard.LEFT)
					{
						kms3d.position.w += 10;
					}
					else if(e.keyCode == Keyboard.RIGHT)
					{
						kms3d.position.w -= 10;
					}
				}				
			);
		}
	}
}